function forgetpassword() {
    var sum = 0
    var that
    class User {
        constructor() {
            that = this
            //功能获取
            this.lowuser = document.getElementById("lowuser") //忘记密码按钮
            this.Interface = document.getElementById("lowpasswordbox") //忘记密码的界面
            this.lowbtn = this.Interface.querySelectorAll("button") //忘记密码界面的button集合界面
            this.otab = document.querySelectorAll(".tab li") //账号密码登入 手机登入 集合
            this.osing = document.querySelector("#sing") //登入按钮 
            this.ocontent = document.querySelectorAll(".form,#form") //tab切换PC端移动端界面        
            this.inte()
            this.getbtn()
        }
        inte() {
            this.password = document.querySelector("#password")
            this.ouser = document.querySelector("#user") //账号输入框input
            this.ble = document.querySelectorAll("#ble")
            this.ouser2 = document.querySelector("#user2")
            this.phone = document.querySelector("#phone")

        }


        //添加事件
        getbtn() {

            this.ouser.onkeyup = this.down.bind(this.ouser, 0)
            this.ouser2.onkeyup = this.down.bind(this.ouser2, 1)
            this.phone.onkeyup = this.down.bind(this.phone, 2)
            this.lowuser.onclick = this.shou //忘记密码按钮一点击实现效果
            this.lowbtn[2].onclick = this.shou //关闭按钮
            // this.user.onblur = this.reg.bind(this)
            for (let i = 0; i < this.otab.length; i++) {
                this.otab[i].index = i
                this.otab[i].onclick = this.tab
            }
            this.osing.onclick = this.sing

        }
        //功能忘记密码功能
        shou() {
            if (that.Interface.style.display == "none") {
                that.Interface.style.display = "block"
            } else {
                that.Interface.style.display = "none"
            }
            var oW = document.documentElement.clientWidth,
                oH = document.documentElement.clientHeight
            var obox = document.querySelector("#lowpasswordbox")
            obox.style.left = (oW - obox.offsetWidth) / 2 + 'px'
            obox.style.top = (oH - obox.offsetHeight) / 2 + 'px'
        }

        // 切换功能
        tab() {
            sum = 0
            that.inte()
            that.otab.forEach((time, index) => {
                time.style.border = "none"
                that.ocontent[index].style.display = "none"

            });
            this.style.borderBottom = "2px solid #3b1de7"
            that.ocontent[this.index].style.display = "block"

        }



        //登入功能
        sing() {
            let username = that.ouser.value
            let password = that.password.value

            console.log(username, password);
            axios.post("uaa/oauth/token", {
                username: username,
                password: password,
                grant_type: "password",
                scope: "all"
            }
            // ,{
            //     Authorization:"Basic Y2xpZW50OnNlY3JldA=="
            // }
            
            ).then(res => {
                localStorage.setItem("Authorization",JSON.stringify(res.data))
                location.href = "index.html"
            }).catch(err => {
                alert("加载失败")

            })

        }

        //按下键盘效果
        down(index) {

            sum = this.value.length
            that.ble[index].innerHTML = sum


        }


    }
    var user = new User()
    // console.log(user.ocontent);

}

//忘记密码函数

forgetpassword()


//验证正则函数
function verification() {
    var that
    class Regular {
        constructor() {
            that = this
            this.reg = /\S/;
            this.uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
            this.myreg = /^[1][3,4,5,6.7,8,9][0-9]{9}$/ //手机号码正则
            this.patten = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/ //密码正则
            this.otab = document.querySelectorAll(".tab li") //账号密码登入 手机登入 集合
            this.odiv = document.createElement("div") //创建一个节点
            // this.lowuser = document.querySelector(".list li input") //忘记密码里面的手机号验证
            this.password = document.querySelector("#password") //输入密码框
            this.inte()
            this.getbtn()
        }
        //动态获取
        inte() {
            this.user = document.getElementById("user") //输入账号框
            this.user2 = document.getElementById("user2")
            this.password2 = document.getElementById("password2")
            // console.log(this.user2);

        }


        getbtn() {
            let text3 = "验证码不能为空"
            let text2 = "请输正确密码"
            let text = "请输入正确的账号"
            let ts = "ts"
            let ts2 = "ts2"
            this.user.onblur = this.shou.bind(this.user, text, this.uPattern, ts)
            this.user2.onblur = this.shou.bind(this.user2, text, this.myreg, ts)
            // this.lowuser.onblur = this.shou.bind(this.lowuser, text, this.myreg, ts2)
            this.password.onblur = this.shou.bind(this.password, text2, this.uPattern, ts)
            this.password2.onblur = this.shou.bind(this.password2, text3, this.reg, ts)



        }
        shou(text, zz, ts) {

            let o = zz.test(this.value, zz)

            if (o == false) {
                this.parentNode.appendChild(that.odiv)
                that.odiv.innerHTML = text
                that.odiv.classList.add(ts)
                this.style.borderColor = "red"

            } else {
                that.odiv.remove()
                this.style.borderColor = "lightgreen"
            }

        }


    }

    let zc = new Regular()

}

verification()
// class User extends Regular{

// }\


function otest(val1, val2, vla3, vla4, vla5) {
    val1.onblur = function () {
        var s = val2.test(val1.value)
        if (!s) {
            this.parentNode.appendChild(vla4, this)
            //ospan.classList.add("ys")
            vla4.innerHTML = vla3
            vla4.classList.add(vla5)
            this.style.borderColor = "red"
        } else {
            vla4.remove()
            this.style.borderColor = "lightgreen"
        }
    }
}
var myreg = /^[1][3,4,5,6.7,8,9][0-9]{9}$/ //手机号码正则
var patten = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/ //密码正则
var reg = /\S/; //空

var input = document.querySelectorAll(".list input")
// console.log(input);
var arrdiv = [
    "ospan", "ospan2", "ospan3", "ospan4",
]
for (let i = 0; i < arrdiv.length; i++) {
    arrdiv[i] = document.createElement("div")
    //    console.log(arrdiv[i]);

}
otest(input[0], myreg, "输入错误", arrdiv[0], "ts2")
otest(input[1], reg, "输入错误", arrdiv[1], "ts3")
otest(input[2], patten, "输入错误", arrdiv[2], "ts2")
otest(input[3], patten, "输入错误", arrdiv[3], "ts2")